<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-default">
      <a class="navbar-brand" href="/">
        <%= fa_icon 'envelope' %> Octobox
      </a>
      <a href="/sync" data-turbolinks="false" class='btn btn-default navbar-btn navbar-right sync'>
        <%= fa_icon 'refresh' %>
      </a>
    </div>
  </div>
</nav>
<div class="container-fluid">
  <div class="row">
    <div class="col-xs-12 col-md-2 table-responsive">
      <table class='table table-condensed'>
        <% @statuses.each do |status, count| %>
          <tr>
            <td>
              <% if status %>
                <%= fa_icon 'envelope' %>
              <% else %>
                <%= fa_icon 'envelope-open' %>
              <% end %>
            </td>
            <td>
              <% if params[:status] == status.to_s %><strong><% end %>
              <%= link_to (status ? 'Unread' : 'Read'), root_path(status: status, type: params[:type], repo: params[:repo], archive: params[:archive]) %>
              <% if params[:status] == status.to_s %></strong><% end %>
            </td>
            <td class='text-center'>
              <span class="label label-muted"><%= count %></span>
            </td>
          </tr>
        <% end %>
        <tr style='border:none;'><td colspan='3' style='border:none;'>&nbsp;</td></tr>
        <% @types.each do |type, count| %>
          <tr>
            <td>
              <%= fa_icon(notification_icon(type))%>
            </td>
            <td>
              <% if params[:type] == type %><strong><% end %>
              <%= link_to type.underscore.humanize, root_path(status: params[:status], type: type, repo: params[:repo], archive: params[:archive]) %>
              <% if params[:type] == type %></strong><% end %>
            </td>
            <td class='text-center'>
              <span class="label label-muted"><%= count %></span>
            </td>
          </tr>
        <% end %>
        <tr style='border:none;'><td colspan='3' style='border:none;'>&nbsp;</td></tr>
        <% @reasons.each do |reason, count| %>
          <tr>
            <td class='text-<%= reason_label(reason) %>'>
              <%= fa_icon('circle')%>
            </td>
            <td>
              <% if params[:reason] == reason %><strong><% end %>
              <%= link_to reason.underscore.humanize, root_path(reason: reason, type: params[:type], repo: params[:repo], archive: params[:archive]) %>
              <% if params[:reason] == reason %></strong><% end %>
            </td>
            <td class='text-center'>
              <span class="label label-muted"><%= count %></span>
            </td>
          </tr>
        <% end %>
        <tr style='border:none;'><td colspan='3' style='border:none;'>&nbsp;</td></tr>
        <% @unread_repositories.sort.each do |repo_name, count| %>
          <tr>
            <td>
              <%= image_tag "https://github.com/#{repo_name.split('/').first}.png?size=40", width: 20 %>
            </td>
            <td>
              <% if params[:repo] == repo_name %><strong><% end %>
              <%= link_to repo_name.split('/').last, root_path(repo: repo_name, archive: params[:archive]) %>
              <% if params[:repo] == repo_name %></strong><% end %>
            </td>
            <td class='text-center'>
              <span class="label label-muted"><%= count %></span>
            </td>
          </tr>
        <% end %>
        <tr style='border:none;'><td colspan='3' style='border:none;'>&nbsp;</td></tr>
        <tr>
          <td>
            <%= fa_icon 'archive' %>
          </td>
          <td>
            <% if params[:archive].present? %><strong><% end %>
            <%= link_to 'Archive', root_path(archive: true) %>
            <% if  params[:archive].present? %><strong><% end %>
          </td>
          <td class='text-center'>

          </td>
        </tr>
	<tr style='border:none;'><td colspan='3' style='border:none;'>&nbsp;</td></tr>
        <tr>
          <td>
            <%= fa_icon 'star', class: 'star' %>
          </td>
          <td>
            <% if params[:starred].present? %><strong><% end %>
            <%= link_to 'Starred', root_path(starred: true, archive: params[:archive]) %>
            <% if  params[:starred].present? %><strong><% end %>
          </td>
          <td class='text-center'>
	    <span class="label label-muted"><%= @starred %></span>
          </td>
        </tr>
      </table>
    </div>
    <div class="col-xs-12 col-md-10 table-responsive">
      <table class='table table-condensed table-hover'>
        <% if @notifications.any? %>
          <%= render @notifications %>
        <% elsif params[:archive].nil? && params[:repo].nil? && params[:type].nil? && params[:status].nil? %>
          <tr>
            <td class='text-center'>
              You're in the clear!
            </td>
          </tr>
        <% else %>
        <tr>
          <td class='text-center'>
            <p>
              <%= link_to 'Nothing to see here', root_path %>
            </p>
          </td>
        </tr>
        <% end %>
      </table>
    </div>
  </div>
</div>
